import { StopRunningService } from './stop.service';
import { Component, OnInit, ViewChild, ViewContainerRef, ComponentRef, ComponentFactoryResolver } from '@angular/core';
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { LayoutComponent } from "../../../global/layout/layout.component";
import * as _ from 'lodash';
import { environment } from '../../../../../environments/environment';
import { AnnuityFileComponent } from "../../modal/file/file.component";
import { FileUploader } from "ng2-file-upload";
import { Util } from 'app/common/util';
import { DataService } from '../../../../services/data.service';
import { AreaDataCnComponent } from "../../../../widgets/area-data-cn/area-data-cn.component";

@Component({
  selector: 'app-stop',
  templateUrl: './stop.component.html',
  styleUrls: ['./stop.component.scss'],
  providers: [StopRunningService]
})
export class StopComponent implements OnInit {
  // lodash
  public _: any = _;
  //所属地区
  public area: any;
  // 菜单数据
  public menuData: any;
  // 菜单权限set
  public menuResourceSet: any = [];
  // 获取模板内的第一个指定组件
  @ViewChild(AreaDataCnComponent)
  public areaDataCnComponent: AreaDataCnComponent;
  // 组合文件模版
  @ViewChild("file", { read: ViewContainerRef })
  file: ViewContainerRef;
  fileComponent: ComponentRef<AnnuityFileComponent>;
  // 续约/终止审核组合文件模版
  @ViewChild("checkFile", { read: ViewContainerRef })
  checkFile: ViewContainerRef;
  checkFileComponent: ComponentRef<AnnuityFileComponent>;
  // 终止组合文件模版
  @ViewChild("terminationFile", { read: ViewContainerRef })
  terminationFile: ViewContainerRef;
  terminationFileComponent: ComponentRef<AnnuityFileComponent>;
  // 组合文件类型
  public groupFileClass = [];
  // 合同扫描
  public ContractScanning = [];
  // 合同备忘与协议
  public ContractAgreement = [];
  // 账户类
  public AccountClass = [];
  // 投资类
  public InvestmentClass = [];
  // 备报确认函
  public onfirmation = [];
  // 业绩考核
  public PerformanceAssessment = [];
  // 受托人附件
  public assignee = [];
  // 关联人员
  public Associates = [];
  // 其他
  public Other = [];


  //  修改运作日期
  public runningData = {
    "dBegin": "",
    "nFundNo": ""
  }
  public accountList = [];
  public index: any;
  public listCount = 5;
  // 年金列表列表是否全选
  public isCheckedAll = false;
  // 用于保存路由中的组合内码
  public nFundNo: any;
  // 上传文件名
  public fileName;
  // 上传文件的名称
  public uploadFileName: any = "";
  // 选择文件状态
  public fileStatus = false;
  // 初始化定义uploader变量,用来配置input中的uploader属性
  public uploader: FileUploader = new FileUploader({});

  //  年金列表数据
  public listData;

  // 用于保存激活的文件tab大类
  public activeFileType = "";
  // 组合上传参数
  public sCreatorNo: any;
  public sCreator: any;
  public sAttachCode: any;
  public nAttachNo: any;
  public sAttachType: any;
  public parentCode: any;
  public parentType: any;
  public sFundType: any;

  // 投资经理列表
  public ManagerList;
  // 项目经理列表
  public ProjectManagerList;
  // 投管人
  public sInvestSelectList: any;
  // 移交投管人
  public sInvestorSelectList: any;
  // 其他投资管理人
  public investorSelectList: any;
  // 项目经理
  public managerSelectList: any;
  // 备案机构、受托人、托管人
  public distionary: any = {
    RECORDORG_TYPE: [],  // 备案机构
    LINK_PRINCIPAL_NO: [],   //受托人
    INVEST: [], // 投管人
    TRUSTEE: []   //  托管人
  }
  // 字典值
  public dictionaryList: any = {
    // RECORDORG_TYPE: [],  // 备案机构
    TERM_TYPE: [],   // 产品类别
    // LINK_PRINCIPAL_NO: [],   // 受托人
    // TRUSTEE: [],   // 托管人
    MANAGER: [],    // 账管人
    AREA: [],   // 所属地区
    CALLING: [], // 所属行业
    CENTRAL_ENTERPRISER: [], // 是否央企
    OTHER_INVESTOR: [],  // 其他投资管理人、移交投管人
    EMISSION_WAY: [],  // 发行方式
    STOP_TYPE: [],
    ANNUITY_TYPE: [],
    //updatd by dujh @20180703 增加字段
    PLAN_TYPE: [] //计划类型
  };

  // 是否模态框查询
  public isQuery: any = false;
  // 年金分页列表post数据
  public getBody = {
    pageIndex: 1,
    pageSize: 10,
    sStatus: "yzhzh",
    sFundType: 4,
    sFullName: '',  //组合名称 
    sFundCode: '', //组合代码 
    sLinkPrincipalNo: '' //受托人
  }
  public postBody = {
    pageIndex: 1,
    pageSize: 10,
    sStatus: "yzhzh",
    sFundType: 4,
    sFullName: '',  //组合名称 
    sFundCode: '', //组合代码 
    sContractName: '',  //合同名称 
    sProductType: '',
    sIsAssetTransfer: '0',  //是否资产移交
    sInvestor: '', //移交投管人
    //dSign: '', //签约日期
    //dConfirm: '', //确认日期
    sRecordorgType: '', //备案机构
    sPlanNo: '', //产品登记号
    //dEffective: '', //生效日期
    //dBegin: '', //开始运作日期
    sTermType: '', //期限 
    // dEnd: '', //到期日
    sIsRenewal: '', //是否自动续约
    sLinkPrincipalNo: '', //受托人
    sManager: '', //账管人
    sPrincipal: '', //委托人
    sTrustee: '', //托管人
    // sOtherInvestor: '', //其他投资管理人
    sProjectManager: '', //项目经理
    sManagerNo: '', //投资经理
    sBenchmark: '', //业绩比较基准
    sArea: '', //所属地区
    sCalling: '', // 所属行业
    sIsCentralEnterpriser: '', // 是否央企
    // sIsContainRight: '', //是否含权类
    // sConfirmationNo: '', //确认函号
    // sEmissionObject: '', //发行对象
    // sEmissionWay: '' //发行方式
    sInvest: '',// 投管人
    //updated by dujh @20180703 
    sPlanType:''//计划类型
  };
  // 年金列表分页配置
  public listPageInfo = {
    currentPageNum: 1,
    pageSize: 10,
    totalPages: 1,
    total: 0,
    pagesShow: 5,
    startRow: 0,
    endRow: 0,
    pageList: [5, 10, 25, 50, 100]
  }
  // 用于控制页面显示
  public showPage: any = '1';
  // 续约/终止列表数据
  public renewList: any;
  // 续约/终止列表全选
  public isRenewCheckedAll: any = false;
  // 续约/终止列表请求体
  public getRenewPost = {
    pageIndex: 1,
    pageSize: 10,
    sFundType: '4',
    prdName: '',
    prdCode: '',
    sType: '3'
  };
  // 续约/终止列表页配置
  public renewPageInfo = {
    currentPageNum: 1,
    pageSize: 10,
    totalPages: 1,
    total: 0,
    pagesShow: 5,
    startRow: 0,
    endRow: 0,
    pageList: [5, 10, 25, 50, 100]
  };
  // 基础列表
  public basicList: any;
  // 基础列表请求体
  public getBasicPost = {
    pageIndex: 1,
    pageSize: 10,
    sStatus: 'yyz',
    sFundType: '4',
    sFundCode: '',
    sFullName: '',
    dEffective: '',
    dEnd: ''
  };
  // 基础列表分页配置
  public basicPageInfo = {
    currentPageNum: 1,
    pageSize: 10,
    totalPages: 1,
    total: 0,
    pagesShow: 5,
    startRow: 0,
    endRow: 0,
    pageList: [5, 10, 25, 50, 100]
  };
  // 续约/终止新增
  public selectFundNo: any = '';
  // 续约模版数据
  public renewBody: any = {
    sTermType: ''
  };
  // 终止模版数据
  public terminationBody: any = {};
  // 审核模版
  public checkBody: any = {};
  //续约终止管理判断业务状态
  public sAuditStatus: any

  constructor(
    public router: Router,
    public resolver: ComponentFactoryResolver,
    private route: ActivatedRoute,
    public layoutComponent: LayoutComponent,
    public stopRunningService: StopRunningService,
    public dataService: DataService
  ) {
    // 用于控制上传附件框是否显示上传、删除文件按钮
    this.dataService.showUploadBtn = true;
    this.route.params.subscribe((data) => {
      this.nFundNo = data.nFundNo;
    })


  }

  ngOnInit() {
    let that = this;
    // 多选下拉框
    window['$'](".select2").select2();
    this.LoadProjectManagerList();
    this.LoadManagerList();
    // 权限处理
    this.dataService.initTree.subscribe(data => {
      if (data) {
        let SessionMenuData = sessionStorage.getItem('menu');
        this.menuData = JSON.parse(SessionMenuData);
        this.menuResourceSet = [];
        _.forEach(this.menuData, (item, index) => {
          if (item.sName == '企业年金') {
            _.forEach(item.children, (it, idx) => {
              if (it.sName == '已终止') {
                that.menuResourceSet = it.resourceSet;
                sessionStorage.setItem('btn-an', this.menuResourceSet);
              }
            })
          }
        })
      }
    })
    let SessionMenuData = sessionStorage.getItem('menu');
    this.menuData = JSON.parse(SessionMenuData);
    this.menuResourceSet = [];
    _.forEach(this.menuData, (item, index) => {
      if (item.sName == '企业年金') {
        _.forEach(item.children, (it, idx) => {
          if (it.sName == '已终止') {
            that.menuResourceSet = it.resourceSet;
            sessionStorage.setItem('btn-an', this.menuResourceSet);
          }
        })
      }
    })
    this.route.params.subscribe((data) => {

      this.index = parseInt(data.index);
      // this.dataService.oto_step = this.index;
      sessionStorage.setItem('pageIndex', this.index);

    });
    this.loadlist();
    // 加载附件树
    //this.loadFileTree();
    // 字典值
    this.dictionaryList = JSON.parse(localStorage.getItem("dictionaryList"));
    this.getDictionary();
  }
  ngAfterViewInit() {
    let that = this;
    // 备案机构
    window['$']('#sRecordorgTypeSelected').select2({ width: '190px', tags: true });
    window['$']('#sRecordorgTypeSelected').on("select2:select", function (e) {
      that.postBody.sRecordorgType = window['$']('#sRecordorgTypeSelected').select2("val");
    })
    // 期限
    window['$']('#sTermTypeSelected').select2({ width: '190px' });
    window['$']('#sTermTypeSelected').on("select2:select", function (e) {
      that.postBody.sTermType = window['$']('#sTermTypeSelected').select2("val");
      // 到期日计算
      // if (that.postBody.dEffective == '' || that.postBody.dEffective == null) {
      //   that.postBody.sTermType = '';
      // } else {
      //   if (that.postBody.sTermType == '' || that.postBody.sTermType == null) {
      //     that.postBody.dEnd = '';
      //   } else if (that.postBody.sTermType == '0') {
      //     that.postBody.dEnd = '';
      //     window['$']("#dEnd").attr("disabled", "disabled");
      //     window['$']("#dEnd").css("background", "#eee");
      //   } else {
      //     window['$']("#dEnd").removeAttr("disabled");
      //     window['$']("#dEnd").css("background", "white");
      //     that.postBody.dEnd = Util.dateIncrease(that.postBody.dEffective, that.postBody.sTermType);
      //   }
      // }
    })
    // 受托人
    window['$']('#sLinkPrincipalNoSelected').select2({ width: '190px', tags: true });
    window['$']('#sLinkPrincipalNoSelected').on("select2:select", function (e) {
      that.postBody.sLinkPrincipalNo = window['$']('#sLinkPrincipalNoSelected').select2("val");
    })
    window['$']('#sLinkPrincipalNoSelecteds').select2({ width: '190px', tags: true });
    window['$']('#sLinkPrincipalNoSelecteds').on("select2:select", function (e) {
      that.getBody.sLinkPrincipalNo = window['$']('#sLinkPrincipalNoSelecteds').select2("val");
    })
    // 账管人
    window['$']('#sManagerSelected').select2({ width: '190px' });
    window['$']('#sManagerSelected').on("select2:select", function (e) {
      that.postBody.sManager = window['$']('#sManagerSelected').select2("val");
    })
    // 托管人
    window['$']('#sTrusteeSelected').select2({ width: '190px', tags: true });
    window['$']('#sTrusteeSelected').on("select2:select", function (e) {
      that.postBody.sTrustee = window['$']('#sTrusteeSelected').select2("val");
    })
    // 组合类型
    window['$']('#sProductTypeSelected').select2({ width: '190px' });
    window['$']('#sProductTypeSelected').on("select2:select", function (e) {
      that.postBody.sProductType = window['$']('#sProductTypeSelected').select2("val");
    })
    // 所属行业
    window['$']('#sCallingSelected').select2({ width: '190px' });
    window['$']('#sCallingSelected').on("select2:select", function (e) {
      that.postBody.sCalling = window['$']('#sCallingSelected').select2("val");
    })
    // 是否央企
    window['$']('#sIsCentralEnterpriserSelected').select2({ width: '190px' });
    window['$']('#sIsCentralEnterpriserSelected').on("select2:select", function (e) {
      that.postBody.sIsCentralEnterpriser = window['$']('#sIsCentralEnterpriserSelected').select2("val");
    })
  }
  //删除组合
  deleteproduct() {
    window['swal']({
      type: "warning",
      showCancelButton: true,
      confirmButtonText: "确认",
      cancelButtonText: "关闭",
      closeOnConfirm: false,
      title: "提示",
      // text: '<select><option value>--请选择--</option><option value>立项中</option><option value>待报会</option><option value>一次反馈</option><option value>二次反馈</option><option value>待受理</option><option value>已获批</option><option value>募集筹备</option><option value>发行中</option><option value>已成立</option><option value>报备中</option><option value>运作中</option><option value>已清盘</option></select>',
      text: "请确认是否删除组合",
      html: true
    });
  }
  edit(type, item?) {
    // this.layoutComponent.nav(null, null, "详情·已终止·年金");
    // this.router.navigate(['pages/annuity/stop/detail/edit/9999']);
    // sessionStorage.setItem('an_isDisplay', 'true');
    let that = this;
    sessionStorage.setItem('parentIndex', 'yzhzh');
    // 组合修改勾选
    let checkProduct = [];
    switch (type) {
      case 'dbclick':
        sessionStorage.setItem('currentTitle', "详情·已终止·年金");
        that.layoutComponent.nav(null, null, "详情·已终止·年金");
        that.router.navigate(['pages/annuity/stop/detail/edit/' + item.nFundNo]);
        break;
      case 'one':
        _.forEach(that.listData, it => {
          if (it.isChecked == true) {
            checkProduct.push(it);
          }
        })
        if (checkProduct.length < 1) {
          window['swal']("提示", "请选择一个组合进行查看", "warning");
        }
        if (checkProduct.length == 1) {
          sessionStorage.setItem('currentTitle', "详情·已终止·年金");
          that.layoutComponent.nav(null, null, "详情·已终止·年金");
          that.router.navigate(['pages/annuity/stop/detail/edit/' + checkProduct[0].nFundNo]);
        }
        if (checkProduct.length > 1) {
          window['swal']("提示", "请选择一个组合进行查看", "warning");
        }
        break;
    }
  }
  // 判断页面查询还是搜索框查询
  loadcheck(type: any) {
    if (type == 'query') {
      this.isQuery = true;
      this.loadlist(1);
    }
    if (type == 'page') {
      this.isQuery = false;
      this.loadlist(1);
    }
  }
  //  列表数据
  loadlist(pageNum?, pageSize?) {
    let that = this;
    let body: any;
    this.isCheckedAll = false;
    // 判断是页面查询还是搜索框查询
    if (this.isQuery) {
      // 清空页面查询条件
      this.getBody.sFullName = '';
      this.getBody.sFundCode = '';
      this.getBody.sLinkPrincipalNo = '';
      window['$']('#sLinkPrincipalNoSelecteds').select2("val", '--请选择--');
      // 转换多选下拉框值
      this.postBody.sInvest = Util.transferValue('.sInvest-select');
      this.postBody.sInvestor = Util.transferValue('.sInvestor-select');
      this.postBody.sProjectManager = Util.transferValue('.manager-select');
      // this.postBody.sInvest = this.ctrlsInves();
      // this.postBody.sInvestor = this.ctrlsInvestor();
      // this.postBody.sOtherInvestor = this.ctrlInvestorId();
      // this.postBody.sProjectManager = this.ctrlManagerId();
      // 去空格
      _.forIn(this.postBody, (value, key) => {
        if (key == 'pageSize' || key == 'pageIndex' || key == 'sFundType') {
          // 这里不做处理，排除number类型
        } else {
          that.postBody[key] = _.trim(that.postBody[key]);
        }
      })
      this.postBody.pageIndex = pageNum ? pageNum : this.listPageInfo.currentPageNum;
      this.postBody.pageSize = pageSize ? pageSize : this.listPageInfo.pageSize
      body = _.cloneDeep(this.postBody);
    } else {
      // 去空格
      this.getBody.sFullName = _.trim(this.getBody.sFullName);
      this.getBody.sFundCode = _.trim(this.getBody.sFundCode);
      this.getBody.pageIndex = pageNum ? pageNum : this.listPageInfo.currentPageNum;
      this.getBody.pageSize = pageSize ? pageSize : this.listPageInfo.pageSize
      body = _.cloneDeep(this.getBody);
    }
    this.stopRunningService.list(body).subscribe(data => {
      if (data) {
        this.listData = data.list;
        this.listPageInfo.currentPageNum = data.pageNum;
        this.listPageInfo.totalPages = data.pages;
        this.listPageInfo.total = data.total;
        this.listPageInfo.startRow = data.startRow;
        this.listPageInfo.endRow = data.endRow;
        window['$']('#annuityStopQuery').modal('hide');
      }
      // // 给表格列支持列拖动效果
      // setTimeout(() => {
      //   Util.colResizable("#fixed-table");
      // }, 100);

      // 给表格列支持列拖动和固定表头效果
      Util.colResizable("#stopList");
    });
  }
  // 导出
  exportExcel() {
    // let that = this;
    // let checkedItem = [];
    // _.forEach(that.listData, item => {
    //   if (item.isChecked == true) {
    //     checkedItem.push(item.nFundNo);
    //   }
    // })
    // let converItem = checkedItem.join(',');
    // let getBody = {
    //   "nFundNoList": converItem,
    //   "sStatus": 'yzhzh',
    //   "sFundType": 4,
    //   "sFullName": '',
    //   "sFundCode": '',
    //   // "sIsRegisterChg": that.postBody.sIsRegisterChg
    // }
    // const iframe = window['$']("<iframe id='downloadiframe'>");
    // iframe.attr('style', 'display:none');
    // //  转码，兼容ie
    // getBody.sFullName = encodeURI(getBody.sFullName)
    // iframe.attr('src', environment.server + '/pms/v1/pension/basicInfo/export/pensionDeptList?token=' + sessionStorage.getItem('token') + '&nFundNoList=' + getBody.nFundNoList + '&sStatus=' + getBody.sStatus + '&sFundType=' + getBody.sFundType + '&sFundCode=' + getBody.sFundCode);
    // window['$']('body').append(iframe);
    // setTimeout("$('#downloadiframe').remove()", 60000);
    let that = this;
    let checkedItem = [];
    let postBody: any;
    _.forEach(this.listData, item => {
      if (item.isChecked) {
        checkedItem.push(item.nFundNo);
      }
    })
    let converItem = checkedItem.join(",");
    // 请求body
    if (this.isQuery) {
      postBody = _.cloneDeep(this.postBody);
      postBody['nFundNoList'] = checkedItem;
      delete postBody.pageIndex;
      delete postBody.pageSize;
    } else {
      postBody = {
        "nFundNoList": checkedItem,
        "sFullName": this.getBody.sFullName,
        "sFundCode": this.getBody.sFundCode,
        "sFundType": this.getBody.sFundType,
        "sStatus": this.getBody.sStatus,
        "sLinkPrincipalNo": this.getBody.sLinkPrincipalNo
      }
    }
    // 请求Url
    let postUrl = environment.server + '/pms/v1/pension/basicInfo/export/pensionDeptList?token=' + sessionStorage.getItem('token');
    // 导出
    this.stopRunningService.exportTarget(postUrl, postBody, '企业年金组合列表-已终止');
  }
  // 列表分页
  pageNavigation(currentPageNum: number) {
    this.listPageInfo.currentPageNum = currentPageNum;
    this.loadlist(this.listPageInfo.currentPageNum, this.listPageInfo.pageSize);
  }
  // 条数分页
  sizeChange(pageSize: number) {
    if (pageSize !== this.listPageInfo.pageSize) {
      this.listPageInfo.pageSize = pageSize;
      this.loadlist();
    }
  }
  delProduct() {
    let that = this;
    let checkedItem = [];
    let checkedStatus = [];
    let checkedFundName = [];
    _.forEach(this.listData, item => {
      if (item.isChecked == true) {
        checkedStatus.push(item.sProductAuditZh);
        checkedFundName.push(item.sFullName);
        checkedItem.push(item.nFundNo);
      }
    });
    let checkedTips = checkedFundName.join("、");
    // if (_.includes(checkedStatus, "审核通过")) {
    //   window["swal"]("提示", "审核通过的数据不能删除", "warning");
    // } else {
    if (checkedItem.length > 0) {
      window["swal"](
        {
          type: "warning",
          showCancelButton: true,
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          closeOnConfirm: false,
          showLoaderOnConfirm: true,
          title: "提示",
          text:
          "<div style='max-height: 200px;overflow-y: auto;'>" +
          "请确认是否删除：" +
          checkedTips +
          "组合" +
          "</div>",
          html: true
        },
        function (isConfirm) {
          if (isConfirm) {
            let putBody: any = {
              nFundNos: checkedItem
            };
            that.stopRunningService.del(putBody).subscribe(data => {
              if (data) {
                window["swal"]("删除成功！", "", "success");
                that.loadlist();
              }
            });
          }
        }
      );
    } else {
      window["swal"]("提示", "请选择一个或多个数据进行删除", "warning");
    }
    // }
  }

  // 显示上传文件框
  showUploadModal() {
    let that = this;
    // 组合勾选
    let checkProduct = [];
    let checkedStatus = [];
    let checkedFundName = [];
    let checkedItem;
    _.forEach(that.listData, item => {
      if (item.isChecked == true) {
        checkProduct.push(item);
        checkedFundName.push(item.sFullName);
        // checkedItem = item;
      }
    });
    let checkedTips = checkedFundName.join("、");
    if (checkProduct.length < 1 || checkProduct.length > 1) {
      window["swal"]("提示", "请选择一个组合", "warning");
    } else if (checkProduct.length == 1) {
      this.sCreator = sessionStorage.getItem('username');
      this.sCreatorNo = sessionStorage.getItem('username');
      this.showFile(checkProduct[0]);
      window['$']('#AnnuityuploadModel').modal('show');
    }
  }
  //关闭模态框
  closeModal() {
    window['$']('#AnnuityuploadModel').modal('hide');
  }

  // 列表全选
  checkedAll() {
    if (this.isCheckedAll) { // 更新为全选
      _.forEach(this.listData, item => {
        item.isChecked = true;
      });
    } else { // 更新为不全选
      _.forEach(this.listData, item => {
        item.isChecked = false;
      });
    }
  }
  // 列表是否全选
  ctrlCheckAll() {
    let that = this;
    let checkList = [];
    _.forEach(this.listData, item => {
      if (item.isChecked == true) {
        checkList.push(item);
      }
    })
    if (checkList.length == this.listData.length) {
      this.isCheckedAll = true;
    } else {
      this.isCheckedAll = false;
    }
  }
  //  显示修改运作日期模态框
  showRunModal() {
    let that = this;
    let checkProduct = [];
    _.forEach(this.listData, item => {
      if (item.isChecked) {
        checkProduct.push(item);
      }
    })
    if (checkProduct.length == 1) {
      this.runningData = _.clone(checkProduct[0]);
      window['$']("#running").modal('show');
    } else {
      window['swal']("提示", "请选择一个组合进行运作日期修改", "warning");
    }
  }
  // 修改运作日期
  changeRunningData() {
    let that = this;
    if (this.runningData.dBegin == '' || this.runningData.dBegin == null) {
      window['swal']("提示", "请选择日期", "warning");
    } else {
      let putBody: any = {
        nFundNo: this.runningData.nFundNo,
        dBegin: this.runningData.dBegin
      }
      this.stopRunningService.changeRunningData(putBody).subscribe(data => {
        if (data) {
          window['$']("#running").modal('hide');
          window['swal']("成功", "运作日期修改成功", "success");
          that.loadlist();
        }
      });
    }
  }
  // 下载附件
  downLoadFile(item) {
    if (item.nAttachNo) {
      Util.attachDownload([item.nAttachNo]);
    } else {
      window['swal']("提示", "请选择文件再下载", "warning");
    }
  }
  // 组合文件模版
  showFile(item) {
    // 判断组件是否已创建，如果创建先注销
    if (this.fileComponent && this.fileComponent.instance) {
      this.fileComponent.destroy();
    }
    // 动态创建组件的实例
    console.log(item);
    this.dataService.sLinkPrincipalNo = '';
    this.dataService.sLinkPrincipal = ''
    const fileComponent = this.resolver.resolveComponentFactory(AnnuityFileComponent);
    this.dataService.sLinkPrincipalNo = item.sLinkPrincipalNo
    console.log('item.sLinkPrincipalNo')
    console.log(this.dataService.sLinkPrincipalNo)
    this.dataService.sLinkPrincipal = item.sLinkPrincipalNoZh
    console.log('this.dataService.sLinkPrincipal')
    console.log(this.dataService.sLinkPrincipal)
    this.fileComponent = this.file.createComponent(fileComponent);
    this.fileComponent.instance.nFundNo = item.nFundNo;
    this.fileComponent.instance.sAttachType = item.sAttachType;
    this.fileComponent.instance.sAttachCode = item.sAttachCode;
    // this.dataService.
    // sAttachCode


  }
  // 显示搜索模态框
  showQuery() {
    window['$']('#annuityStopQuery').modal('show');
  }
  // 重置搜索
  resetQuery() {
    this.postBody.sFundCode = ''; //组合代码 
    this.postBody.sFullName = '';  //组合名称 
    this.postBody.sContractName = '';  //合同名称 
    this.postBody.sIsAssetTransfer = '0';  //是否资产移交
    this.postBody.sInvestor = '';
    //this.postBody.dSign = ''; //签约日期
    //this.postBody.dConfirm = ''; //确认日期
    this.postBody.sRecordorgType = ''; //备案机构
    this.postBody.sPlanNo = ''; //产品登记号
    // this.postBody.sConfirmationNo = ''; //确认函号
    // this.postBody.sEmissionObject = ''; //发行对象
    // this.postBody.sEmissionWay = ''; //发行方式
    //this.postBody.dEffective = ''; //生效日期
    //this.postBody.dBegin = ''; //开始运作日期
    this.postBody.sTermType = ''; //期限 
    //this.postBody.dEnd = ''; //到期日
    this.postBody.sIsRenewal = ''; //是否自动续约
    this.postBody.sLinkPrincipalNo = ''; //受托人
    this.postBody.sManager = ''; //账管人
    this.postBody.sPrincipal = ''; //委托人
    this.postBody.sTrustee = ''; //托管人
    // this.postBody.sOtherInvestor = ''; //其他投资管理人
    this.postBody.sProjectManager = ''; //项目经理
    this.postBody.sManagerNo = ''; //投资经理
    this.postBody.sBenchmark = ''; //业绩比较基准
    this.postBody.sCalling = ''; // 所属行业
    this.postBody.sIsCentralEnterpriser = ''; // 是否央企
    //updated by dujh @20180703 start 
    this.postBody.sPlanType = ''; //计划类型
    //updated by dujh @20180703 end
    // this.postBody.sIsContainRight = ''; //是否含权类
    this.postBody.sInvest = ''; // 投管人
    this.postBody.sArea = ''; //所属地区
    this.areaDataCnComponent.reset(); // 所属地区
    window['$']('#sCallingSelected').select2("val", '--请选择--'); // 所属行业
    window['$']('#sIsCentralEnterpriserSelected').select2("val", '--请选择--'); // 是否央企
    //updated by dujh @20180703 start 
    window['$']('#sPlanTypeSelected').select2("val", "--请选择--");//计划类型
    //updated by dujh @20180703 end 
    window['$']('#sRecordorgTypeSelected').select2("val", '--请选择--'); // 备案机构
    window['$']('#sTermTypeSelected').select2("val", '--请选择--'); // 期限
    window['$']('#sLinkPrincipalNoSelected').select2("val", '--请选择--'); // 受托人   
    window['$']('#sManagerSelected').select2("val", '--请选择--'); // 账管人
    window['$']('#sTrusteeSelected').select2("val", '--请选择--'); // 托管人
    // window['$']('#sManagerNoSelected').select2("val", '--请选择--'); // 投资经理
    window['$']('#sAreaSelected').select2("val", '--请选择--'); // 所属地区
    window['$']('#sProductTypeSelected').select2("val", '--请选择--'); // 组合类型
    window['$']('.sInvestor-select').select2("val", '--请选择--'); // 移交投管人
    // window['$']('.investor-select').select2("val", '--请选择--'); // 其他投资管理人
    window['$']('.manager-select').select2("val", '--请选择--'); // 项目经理
    window['$']('.sInvest-select').select2("val", '--请选择--'); // 投管人
  }
  // 是否资产移交控制
  IsAssetTransfer() {
    let that = this;
    if (this.postBody.sIsAssetTransfer == '0') {
      this.postBody.sInvestor = '';
      window['$']('.sInvestor-select').select2("val", '--请选择--'); // 移交投管人
    }
  }
  //获取基金经理下拉框数据
  LoadManagerList() {
    let that = this;
    that.stopRunningService.getManagerList().subscribe(data => {
      if (data) {
        that.ManagerList = data;
      }
    });
  }
  //获取基金经理下拉框数据
  LoadProjectManagerList() {
    let that = this;
    that.stopRunningService.getProjectManagerList().subscribe(data => {
      if (data) {
        that.ProjectManagerList = data;
      }
    });
  }
  // 投管人
  // ctrlsInves() {
  //   let investorList: any;
  //   let investorChecked = [];
  //   let selected = window['$']('.sInvest-select').val();
  //   _.forEach(selected, item => {
  //     let index1 = item.indexOf("'");
  //     let index2 = item.lastIndexOf("'");
  //     let sales = item.substring(index1 + 1, index2);
  //     investorChecked.push(sales);
  //   })
  //   investorList = investorChecked.join(",");
  //   return investorList;
  // }
  // 移交投管人sInvestor
  // ctrlsInvestor() {
  //   let investorList: any;
  //   let investorChecked = [];
  //   let selected = window['$']('.sInvestor-select').val();
  //   _.forEach(selected, item => {
  //     let index1 = item.indexOf("'");
  //     let index2 = item.lastIndexOf("'");
  //     let sales = item.substring(index1 + 1, index2);
  //     investorChecked.push(sales);
  //   })
  //   investorList = investorChecked.join(",");
  //   return investorList;
  // }
  // 其他投资管理人
  // ctrlInvestorId() {
  //   let investorIdList: any;
  //   let investorChecked = [];
  //   let selected = window['$']('.investor-select').val();
  //   _.forEach(selected, item => {
  //     let index1 = item.indexOf("'");
  //     let index2 = item.lastIndexOf("'");
  //     let sales = item.substring(index1 + 1, index2);
  //     investorChecked.push(sales);
  //   })
  //   investorIdList = investorChecked.join(",");
  //   return investorIdList;
  // }
  // 项目经理
  // ctrlManagerId() {
  //   let managerIdList: any;
  //   let managerChecked = [];
  //   let selected = window['$']('.manager-select').val();
  //   _.forEach(selected, item => {
  //     let index1 = item.indexOf("'");
  //     let index2 = item.lastIndexOf("'");
  //     let sales = item.substring(index1 + 1, index2);
  //     managerChecked.push(sales);
  //   })
  //   managerIdList = managerChecked.join(",");
  //   return managerIdList;
  // }
  changePage(type: any) {
    if (type == '1') {
      this.showPage = '1';
      this.loadlist(1);
    } else if (type == '2') {
      this.showPage = '2';
      this.getRenewList(1);
    }
  }
  // 续约/终止列表
  getRenewList(pageNum?, pageSize?) {
    let that = this;
    this.isRenewCheckedAll = false;
    this.getRenewPost.prdName = _.trim(this.getRenewPost.prdName);
    this.getRenewPost.prdCode = _.trim(this.getRenewPost.prdCode);
    this.getRenewPost.pageIndex = pageNum ? pageNum : this.renewPageInfo.currentPageNum;
    this.getRenewPost.pageSize = pageSize ? pageSize : this.renewPageInfo.pageSize;
    this.stopRunningService.getRenewList(this.getRenewPost).subscribe(data => {
      if (data) {
        that.renewList = data.list;
        that.renewPageInfo.currentPageNum = data.pageNum;
        that.renewPageInfo.totalPages = data.pages;
        that.renewPageInfo.total = data.total;
        that.renewPageInfo.startRow = data.startRow;
        that.renewPageInfo.endRow = data.endRow;
      }
    });
  }
  // 续约/终止个数分页
  renewpageSizeChange(pageSize: number) {
    if (pageSize !== this.renewPageInfo.pageSize) {
      this.renewPageInfo.pageSize = pageSize;
      this.getRenewList();
    }
  }
  // 续约/终止条数分页
  renewPageNavigation(currentPageNum: number) {
    this.renewPageInfo.currentPageNum = currentPageNum;
    this.getRenewList(this.renewPageInfo.currentPageNum, this.renewPageInfo.pageSize);
  }
  // 续约/终止列表全选
  renewCheckedAll() {
    if (this.isRenewCheckedAll) {
      _.forEach(this.renewList, item => {
        item.isChecked = true;
      });
    } else {
      _.forEach(this.renewList, item => {
        item.isChecked = false;
      });
    }
  }
  // 续约/终止列表是否全选
  ctrlRenewCheckAll() {
    let that = this;
    let checkList = [];
    _.forEach(this.renewList, item => {
      if (item.isChecked) {
        checkList.push(item);
      }
    })
    if (checkList.length == this.renewList.length) {
      this.isCheckedAll = true;
    } else {
      this.isCheckedAll = false;
    }
  }
  // 获取基础列表数据
  getBasicList(pageNum?, pageSize?) {
    let that = this;
    this.selectFundNo = '';
    this.getBasicPost.sFundCode = _.trim(this.getBasicPost.sFundCode);
    this.getBasicPost.sFullName = _.trim(this.getBasicPost.sFullName);
    this.getBasicPost.pageIndex = pageNum ? pageNum : this.basicPageInfo.currentPageNum;
    this.getBasicPost.pageSize = pageSize ? pageSize : this.basicPageInfo.pageSize;
    this.stopRunningService.getBasicList(this.getBasicPost).subscribe(data => {
      if (data) {
        that.basicList = data.list;
        that.basicPageInfo.currentPageNum = data.pageNum;
        that.basicPageInfo.totalPages = data.pages;
        that.basicPageInfo.total = data.total;
        that.basicPageInfo.startRow = data.startRow;
        that.basicPageInfo.endRow = data.endRow;
      }
    })
  }
  // 基础个数分页
  basicpageSizeChange(pageSize: number) {
    if (pageSize !== this.basicPageInfo.pageSize) {
      this.basicPageInfo.pageSize = pageSize;
      this.getBasicList();
    }
  }
  // 基础页码分页
  baiscPageNavigation(currentPageNum: number) {
    this.basicPageInfo.currentPageNum = currentPageNum;
    this.getBasicList(this.basicPageInfo.currentPageNum, this.basicPageInfo.pageSize);
  }
  // 续约/终止新增modal
  add() {
    this.getBasicList();
    window['$']("#add").modal('show');
  }
  // 续约/终止新增选择
  selectItem(nFundNo) {
    this.selectFundNo = nFundNo;
  }
  // 续约/终止新增保存
  addRenew() {
    let that = this;
    if (this.selectFundNo == '') {
      window['swal']("提示", "请选择一条组合进行添加!", "warning");
    } else {
      window['swal']({
        type: "warning",
        showCancelButton: true,
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        closeOnConfirm: false,
        showLoaderOnConfirm: true,
        title: "提示",
        text: "是否确认添加该条流水记录?",
        html: true
      },
        function (isConfirm) {
          if (isConfirm) {
            that.stopRunningService.addRenew(that.selectFundNo).subscribe(data => {
              if (data) {
                window['$']("#add").modal('hide');
                window['swal']("成功", "添加成功", "success");
                that.getRenewList();
                that.selectFundNo = '';
              }
            })
          }
        })
    }
  }
  // 续约/终止删除
  del() {
    let that = this;
    let checkedItem = [];
    let checkedStatus = [];
    let checkedFundName = [];
    _.forEach(this.renewList, item => {
      if (item.isChecked == true) {
        checkedItem.push(item.nRenewTerminationNo);
        checkedStatus.push(item.sAuditStatus);
        checkedFundName.push(item.sFullName);
      }
    })
    let checkedTips = checkedFundName.join("、");
    if (_.includes(checkedStatus, '1')) {
      window['swal']("提示", "审核通过的数据不能删除", "warning");
    } else {
      if (checkedItem.length > 0) {
        window['swal']({
          type: "warning",
          showCancelButton: true,
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          closeOnConfirm: false,
          showLoaderOnConfirm: true,
          title: "提示",
          text: "<div style='max-height: 200px;overflow-y: auto;'>" + "请确认是否删除：" + checkedTips + "组合" + "</div>",
          html: true
        }, function (isConfirm) {
          if (isConfirm) {
            let putBody: any = {
              "fundNoMap": checkedItem
            }
            that.stopRunningService.delRenew(putBody).subscribe(data => {
              if (data) {
                window['swal']("删除成功！", '', "success")
                that.getRenewList();
                // that.ctrlCheckAll(that.renewList,'isRenewCheckedAll');
              }
            })
          }
        })
      } else {
        window['swal']("提示", "请选择一个或多个数据进行删除", "warning");
      }
    }

  }
  // 续约/终止撤销
  cel() {
    let that = this;
    let checkProduct = [];
    _.forEach(this.renewList, item => {
      if (item.isChecked == true) {
        checkProduct.push(item);
      }
    })
    if (checkProduct.length == 1) {
      if (checkProduct[0].sAuditStatus == 1) {
        let checkItem = _.clone(checkProduct[0]);
        checkItem.sAuditStatus = 0;
        delete checkItem.isChecked;
        window['swal']({
          type: "warning",
          showCancelButton: true,
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          closeOnConfirm: false,
          showLoaderOnConfirm: true,
          title: "提示",
          text: "请确认是否撤销",
          html: true
        }, function (isConfirm) {
          if (isConfirm) {
            that.stopRunningService.checkRenew(checkItem).subscribe(data => {
              if (data) {
                window['swal']("成功", "撤销成功", "success");
                that.getRenewList();
              }
            })
          }
        })
      } else {
        window['swal']("提示", "请选择审核通过的数据进行撤销", "warning");
      }
    } else {
      window['swal']("提示", "请选择一条数据进行撤销", "warning");
    }
  }
  // 续约/终止修改
  change() {
    let that = this;
    let checkProduct = [];
    _.forEach(this.renewList, item => {
      if (item.isChecked == true) {
        checkProduct.push(item);
      }
    })
    if (checkProduct.length == 1) {
      // 业务类型填上并且审核状态不为”已审核”的记录才能进行修改
      this.sAuditStatus = checkProduct[0].sAuditStatus;
      if (checkProduct[0].sType == 3 || checkProduct[0].sType == 5) {
        if (checkProduct[0].sAuditStatus == 1) {
          window['swal']("提示", "审核通过的数据不可修改", "warning");
        } else {
          // 续约
          // if (checkProduct[0].sType == 2) {
          //   this.renewBody = _.clone(checkProduct[0]);
          //   // 用于控制新的到期日禁用
          //   if (this.renewBody.sTermType == '0') {
          //     this.renewBody.dNewEnd = '';
          //     window['$']("#dNewEnd").attr("disabled", "disabled");
          //     window['$']("#dNewEnd").css("background", "#eee");
          //   } else {
          //     window['$']("#dNewEnd").removeAttr("disabled");
          //     window['$']("#dNewEnd").css("background", "white");
          //   }
          //   this.showRenewFile(checkProduct[0]);
          //   window['$']("#renew").modal('show');
          // }
          // 终止
          if (checkProduct[0].sType == 3 || checkProduct[0].sType == 5) {
            this.terminationBody = _.clone(checkProduct[0]);
            this.showTerminationFile(checkProduct[0]);
            window['$']("#termination").modal('show');
          }
        }
      } else {
        window['swal']("提示", "请选择终止状态的数据进行操作", "warning");
        // window['swal']("提示", "业务类型为空，请先进行续约或终止操作", "warning");
      }
    } else {
      window['swal']("提示", "请选择一条数据进行修改", "warning");
    }
  }
  // 终止modal
  showTermination(item) {
    this.sAuditStatus = item.sAuditStatus;
    this.terminationBody = _.clone(item);
    this.showTerminationFile(item);
    window['$']("#termination").modal('show');
  }
  // 终止必填
  requiredTermination() {
    if (this.terminationBody.dStopDate == '' || this.terminationBody.dStopDate == null) {
      window['swal']("提示", "终止日期不可为空", "warning");
      return false;
    } else {
      return true;
    }
  }
  // 终止保存
  saveTermination() {
    let that = this;
    // 终止为业务类型3
    this.terminationBody.sType = 3;
    this.terminationBody.sAuditStatus = 0;
    delete this.terminationBody.isChecked;
    if (this.requiredTermination()) {
      window['swal']({
        type: "warning",
        showCancelButton: true,
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        closeOnConfirm: false,
        showLoaderOnConfirm: true,
        title: "提示",
        text: "是否确认添加终止信息?",
        html: true
      }, function (isConfirm) {
        if (isConfirm) {
          that.stopRunningService.updateRenewTermination(that.terminationBody).subscribe(data => {
            if (data) {
              window['$']("#termination").modal('hide');
              window['swal']("成功", "终止修改成功", "success");
              that.destroyAllModal('terminationFileComponent');
              that.getRenewList();
            }
          })
        }
      })
    }
  }
  // 终止组合文件模版
  showTerminationFile(item) {
    if (this.terminationFileComponent && this.terminationFileComponent.instance) {
      this.terminationFileComponent.destroy();
    }
    this.dataService.showUploadBtn = true;
    const terminationFileComponent = this.resolver.resolveComponentFactory(AnnuityFileComponent);
    this.terminationFileComponent = this.terminationFile.createComponent(terminationFileComponent);
    this.terminationFileComponent.instance.nFundNo = item.nFundNo;
    this.terminationFileComponent.instance.sAttachType = item.sAttachType;
    this.terminationFileComponent.instance.sAttachCode = item.sAttachCode;
  }
  // 续约/终止审核
  check() {
    let that = this;
    let checkProduct = [];
    _.forEach(this.renewList, item => {
      if (item.isChecked == true) {
        checkProduct.push(item);
      }
    })
    if (checkProduct.length == 1) {
      // 判断业务类型是否存在,2为续约/3为终止
      if (checkProduct[0].sType == 2 || checkProduct[0].sType == 3) {
        // 判断是否为待审核状态
        if (checkProduct[0].sAuditStatus == 0) {
          // 判断是否为自动续约
          if (checkProduct[0].sType == 2 && checkProduct[0].sIsRenewal == 1 && (checkProduct[0].dNewBegin == '' || checkProduct[0].dNewBegin == null)) {
            window['swal']("提示", "请前往续约修改面板填写新的开始日期与新的到期日期", "warning");
            // 判断是否为自动终止
          } else if (checkProduct[0].sType == 3 && checkProduct[0].sIsRenewal == 0 && (checkProduct[0].dStopDate == '' || checkProduct[0].dStopDate == null)) {
            window['swal']("提示", "请前往终止修改面板填写终止日期", "warning");
          } else {
            this.checkBody = _.clone(checkProduct[0]);
            this.showCheckFile(checkProduct[0]);
            window['$']("#check").modal('show');
          }
        } else {
          window['swal']("提示", "请选择待审核状态的组合进行审核", "warning");
        }
      } else {
        window['swal']("提示", "请选择终止状态的数据进行操作", "warning");
        // window['swal']("提示", "业务类型为空，请先进行续约或终止操作", "warning");
      }
    } else {
      window['swal']("提示", "请选择一条数据进行审核", "warning");
    }
  }
  // 审核通过
  checkPass() {
    let that = this;
    this.checkBody.sAuditStatus = 1;
    delete this.checkBody.isChecked;
    window['swal']({
      type: "warning",
      showCancelButton: true,
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      closeOnConfirm: false,
      showLoaderOnConfirm: true,
      title: "提示",
      text: "是否确认通过?",
      html: true
    }, function (isConfirm) {
      if (isConfirm) {
        that.stopRunningService.checkRenew(that.checkBody).subscribe(data => {
          if (data) {
            window['$']("#check").modal('hide');
            window['swal']("成功", "审核通过", "success");
            that.getRenewList();
          }
        })
      }
    })
  }
  // 审核打回
  checkRepulse() {
    let that = this;
    this.checkBody.sAuditStatus = 2;
    delete this.checkBody.isChecked;
    window['swal']({
      type: "warning",
      showCancelButton: true,
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      closeOnConfirm: false,
      showLoaderOnConfirm: true,
      title: "提示",
      text: "是否确认打回?",
      html: true
    }, function (isConfirm) {
      if (isConfirm) {
        that.stopRunningService.checkRenew(that.checkBody).subscribe(data => {
          if (data) {
            window['$']("#check").modal('hide');
            window['swal']("成功", "打回成功", "success");
            that.getRenewList();
          }
        })
      }
    })
  }
  // 续约/终止审核组合文件模版
  showCheckFile(item) {
    if (this.checkFileComponent && this.checkFileComponent.instance) {
      this.checkFileComponent.destroy();
    }
    this.dataService.showUploadBtn = false;
    const checkFileComponent = this.resolver.resolveComponentFactory(AnnuityFileComponent);
    this.checkFileComponent = this.checkFile.createComponent(checkFileComponent);
    this.checkFileComponent.instance.nFundNo = item.nFundNo;
    this.checkFileComponent.instance.sAttachType = item.sAttachType;
    this.checkFileComponent.instance.sAttachCode = item.sAttachCode;
  }
  //删除模态框
  destroyAllModal(item) {
    switch (item) {
      // case 'renewFileComponent':
      //   if (this.renewFileComponent) {
      //     this.renewFileComponent.destroy();
      //   }
      //   break;
      case 'checkFileComponent':
        if (this.checkFileComponent) {
          this.checkFileComponent.destroy();
        }
        break;
      // case 'terminationFileComponent':
      //   if (this.terminationFileComponent) {
      //     this.terminationFileComponent.destroy();
      //   }
      //   break;
    }
    this.tabActive();
  }
  /**
  * 重置modal
  */
  tabActive() {
    window['$']("#tab8").removeClass('active');
    window['$']("#tab_8").removeClass('active');
    window['$']("#tabEightContent").attr('aria-expanded', "false");
    window['$']("#tab7").addClass('active');
    window['$']("#tab_7").addClass('active');
    window['$']("#tabSevenContent").attr('aria-expanded', "true");
    window['$']("#tab4").removeClass('active');
    window['$']("#tab_4").removeClass('active');
    window['$']("#tabFourContent").attr('aria-expanded', "false");
    window['$']("#tab3").addClass('active');
    window['$']("#tab_3").addClass('active');
    window['$']("#tabThridContent").attr('aria-expanded', "true");
    window['$']("#tab6").removeClass('active');
    window['$']("#tab_6").removeClass('active');
    window['$']("#tabSixContent").attr('aria-expanded', "false");
    window['$']("#tab5").addClass('active');
    window['$']("#tab_5").addClass('active');
    window['$']("#tabFiveContent").attr('aria-expanded', "true");
  }
  // 续约/终止导出
  exportRenew() {
    let that = this;
    let checkedItem = [];
    _.forEach(this.renewList, item => {
      if (item.isChecked) {
        checkedItem.push(item.nRenewTerminationNo);
      }
    })
    let converItem: any = checkedItem.join(',');
    let getBody = {
      "renewTerminationNoList": converItem,
      "sFundType": this.getRenewPost.sFundType,
      "prdName": this.getRenewPost.prdName,
      "prdCode": this.getRenewPost.prdCode,
      "sType": this.getRenewPost.sType
    }
    const iframe = window['$']("<iframe id='downloadiframe'>");
    iframe.attr('style', 'display:none');
    //  转码，兼容ie
    getBody.prdName = encodeURI(getBody.prdName);
    iframe.attr('src', environment.server + '/pms/v1/pension/renewTerminationInfo/export/renewTerminationInfo?token=' + sessionStorage.getItem('token') + '&renewTerminationNoList=' + getBody.renewTerminationNoList + '&sFundType=' + getBody.sFundType + '&prdName=' + getBody.prdName + '&prdCode=' + getBody.prdCode + '&sType=' + getBody.sType);
    window['$']('body').append(iframe);
    setTimeout("$('#downloadiframe').remove()", 60000);
  }
  // 点击表格头排序
  orderData(colName, dataList, dataListName) {
    let listDataAsc = _.orderBy(dataList, [colName], ["asc"]);
    if (JSON.stringify(dataList) == JSON.stringify(listDataAsc)) {
      listDataAsc = _.orderBy(dataList, [colName], ["desc"]);
    }
    switch (dataListName) {
      case 'listData':
        this.listData = listDataAsc;
        break;
      case 'renewList':
        this.renewList = listDataAsc;
        break;
    }
  }
  OnAreaChg(event) {
    if (event[1] == '--请选择--' && event[0] != '--请选择--') {
      this.postBody.sArea = this.postBody.sArea + ',' + event[0]
    } else if (event[0] == '--请选择--') {
      this.postBody.sArea = '';
    } else {
      this.postBody.sArea = this.postBody.sArea + ',' + event[0] + "-" + event[1]
    }
  }
  OnAreaCodeChg(event) {
    this.postBody.sArea = event;
  }
  // 获取备案机构、受托人、托管人下拉框值
  getDictionary() {
    let that = this;
    this.stopRunningService.getDictionary().subscribe(data => {
      if (data) {
        that.distionary.RECORDORG_TYPE = data.RECORDORG_TYPE;
        that.distionary.LINK_PRINCIPAL_NO = data.LINK_PRINCIPAL_NO;
        that.distionary.TRUSTEE = data.TRUSTEE;
      }
    })
  }
}
